package demo.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import demo.utils.PageUtils;


import demo.dao.BrandDao;
import demo.entity.BrandEntity;
import demo.service.BrandService;
import demo.utils.Query;


@Service("brandService")
public class BrandServiceImpl extends ServiceImpl<BrandDao, BrandEntity> implements BrandService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper qr = new QueryWrapper<BrandEntity>();
        String brandName = (String) params.get("brandName");
        Integer status = (Integer) params.get("status");
        if(StringUtils.isNotBlank(brandName) && !"".equals(brandName)){
            qr.like("brand_name",brandName);
        }
        if(status != null){
            qr.eq("status",status);
        }

        IPage<BrandEntity> page = this.page(
                new Query<BrandEntity>().getPage(params),
                qr
        );

        return new PageUtils(page);
    }

}